from django.shortcuts import render
from django.http import JsonResponse
from .models import *
from .functions import *


# 联系我们主页
def contact(request):
    mess = get_messages(request)
    return render(request,"contact/contact.html",locals())

# 表单提交ajax
def contact_post(request):
    # 验证用户输入
    if check_contact_post(request):
        # 存入数据库
        try:
            Contact.objects.save_contact_message(request)
            return JsonResponse({"ret":1})
        except:
            pass
